package net.comm.user.db;


import java.sql.ResultSet;
import java.sql.SQLException;


import net.comm.user.bean.BaseContacts;
import net.comm.util.StringUtil;

import org.sakaiproject.db.api.SqlReader;

public class DbContactsService implements SqlReader
{

	/**
	 * Read from the result one set of fields to create a Resource.
	 * 
	 * @param result
	 *        The Sql query result.
	 * @return The Resource object.
	 */
	public Object readSqlResultRecord(ResultSet result)
	{
		try
		{
			
			int  userID = result.getInt(1);		//会员ID
			String  mobile = StringUtil.getValue(result.getString(2));		//手机				
			String  tel = StringUtil.getValue(result.getString(3));			//商务电话
			String  famtel = StringUtil.getValue(result.getString(4));		//家庭电话
			String  fax = StringUtil.getValue(result.getString(5));			//传真号码
			String  qQ = StringUtil.getValue(result.getString(6));			//QQ
			String  msn = StringUtil.getValue(result.getString(7));			//MSN		
			String  email = StringUtil.getValue(result.getString(8));		//通讯地址
			String  addr = StringUtil.getValue(result.getString(9));		//通讯地址
			String  postcode = StringUtil.getValue(result.getString(10));	//邮编
			String  offwebsite = StringUtil.getValue(result.getString(11));	//官方网址
			String  perwebsite = StringUtil.getValue(result.getString(12));	//个人网址
			String  blog = StringUtil.getValue(result.getString(13));		//个人博客
			String  mTime = StringUtil.getValue(result.getString(14));		//最后修改日期

			// create the Resource from these fields
			return new BaseContacts( userID,  mobile, tel, famtel,fax, qQ, msn, email, addr, postcode,
					offwebsite, perwebsite, blog,mTime );
		}
		catch (SQLException e)
		{
			return null;
		}
		
	}
}
